//
//  VCodeView.swift
//  ShiZhe
//
//  Created by 陈卿伟 on 16/8/31.
//  Copyright © 2016年 陈卿伟. All rights reserved.
//

import UIKit

class VCodeView: UIView {
    
    var phoneLabel:UILabel!//电话号码的label
    var provingTextField:UITextField!//验证码输入框
    var provingButton:UIButton!//发送验证码的按钮
    var registerButton:UIButton!//确定注册按钮
    
    override init(frame: CGRect) {
        phoneLabel = UILabel()
        provingTextField = UITextField()
        provingButton = UIButton()
        registerButton = UIButton()
         super.init(frame: frame)
        self.createHintlabel()
        self.createPhoneLabel()
        self.createVcodeTextField()
        self.createRegisterButton()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    
    override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
        self.provingTextField.resignFirstResponder()
    }
    
    
    
    //创建提示文字
    func createHintlabel(){
        let labelTop = UILabel(frame: CGRect(x: 0,y: 34*SCALEH,width: WidthAPP,height: 18*SCALEH))
        labelTop.text = "验证码已发送至"
        labelTop.textAlignment = .Center
        labelTop.textColor = Theme.GrayColor
        labelTop.font = BaseFunc.getCustomFont(15)
        self.addSubview(labelTop)
        
        let labelBottom = UILabel(frame: CGRect(x: 0,y: 114*SCALEH,width: WidthAPP,height: 18*SCALEH))
        labelBottom.text = "请注意查看"
        labelBottom.textAlignment = .Center
        labelBottom.textColor = Theme.GrayColor
        labelBottom.font = BaseFunc.getCustomFont(15)
        self.addSubview(labelBottom)
    }
    
    //创建电话号码label
    func createPhoneLabel(){
        phoneLabel.frame = CGRect(x: 0,y: 70*SCALEH,width: WidthAPP,height: 26*SCALEH)
        phoneLabel.textAlignment = .Center
        phoneLabel.font = BaseFunc.getCustomFont(25)
        phoneLabel.textColor = UIColor.blackColor()
        self.addSubview(phoneLabel)
    }
    
    //创建验证码输入框
    func createVcodeTextField(){
        provingTextField.frame = CGRect(x: 32*SCALEW,y: 150*SCALEH,width: 311*SCALEW,height: 39*SCALEH)
        provingTextField.placeholder = "请输入收到的验证码"
        provingTextField.keyboardType = .NumberPad
        provingTextField.font = BaseFunc.getSystemFont(14.5)
        provingTextField.backgroundColor = UIColor.whiteColor()
        let view1 = UIView(frame: CGRect(x: 0,y: 0,width: 10,height: 1))
        provingTextField.leftView = view1
        provingTextField.leftViewMode = .Always
        provingTextField.layer.borderWidth = 1
        provingTextField.layer.borderColor = BaseFunc.createCustomColor(240, b: 240, g: 240, a: 1).CGColor
        provingTextField.layer.cornerRadius = 5
        self.addSubview(provingTextField)
        
        provingButton.frame = CGRect(x: WidthAPP-37*SCALEW-100*SCALEW,y: 155*SCALEH,width: 100*SCALEW,height: 29*SCALEH)
        provingButton.setTitleColor(UIColor.whiteColor(), forState: UIControlState())
        provingButton.setTitle("发送验证码", forState: UIControlState())
        provingButton.titleLabel?.font = BaseFunc.getCustomFont(12)
        provingButton.backgroundColor = UIColor.redColor()
        provingButton.layer.cornerRadius = 5
        self.addSubview(provingButton)
    }
    
    //创建注册按钮
    func createRegisterButton(){
        registerButton.frame = CGRect(x: 33*SCALEW,y: 202*SCALEH,width: 309*SCALEW,height: 50*SCALEH)
        registerButton.setTitle("注册并登录", forState: UIControlState())
        registerButton.setTitleColor(UIColor.whiteColor(), forState: UIControlState())
        registerButton.backgroundColor = UIColor.blackColor()
        registerButton.titleLabel?.font = BaseFunc.getCustomFont(18)
        registerButton.layer.cornerRadius = 5
        self.addSubview(registerButton)
    }

}




